<template>
  <!-- 新建文件夹对话框 -->
  <el-dialog
    :title="modalTitle"
    width="400px"
    :visible.sync="visible"
    @close="onClose"
    class="file-input-dialog"
  >
    <el-date-picker
      v-model="date"
      :type="pickerType"
      :format="pickerType === 'week' ? 'yyyy 第 WW 周' : null"
      placeholder="选择日期"
      style="width: 100%"
    />
    <div
      slot="footer"
      class="dialog-footer"
    >
      <el-button
        size="small"
        @click="onClose"
      >取 消</el-button>
      <el-button
        size="small"
        type="primary"
        :disabled="!date"
        @click="() => onSubmit(date)"
      >确 定</el-button>
    </div>
  </el-dialog>
</template>
<script>
export default {
  name: "DateSelectFormModal",
  props: {
    onSubmit: {
      type: Function
    },
    onClose: {
      type: Function
    },
    dialogVisible: {
      type: Boolean,
      default: false
    },
    modalTitle: {
      type: String,
      default: ""
    },
    pickerType: {
      type: String,
      default: 'date'
    }
  },
  watch: {
    dialogVisible(value) {
      this.visible = value;
    }
  },
  data() {
    return {
      visible: false,
      date: "",
      option: "toPdf"
    };
  }
};
</script>
<style lang="scss">
.file-input-dialog {
  .el-select {
    width: 146px;
  }
}
</style>